-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix common package to work with node16 module resolution. #627
Conversation
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.cjs", | ||
"import": "./dist/index.mjs" | ||
"require": { "types": "./dist/cjs/index.d.ts", "default": "./dist/cjs/index.cjs"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CJS and ESM have to be in different folders in order for this approach to work.
@@ -13,8 +13,7 @@ | |||
"sourceMap": true, | |||
"declaration": true, | |||
"declarationMap": true, // enables importers to jump to source | |||
"stripInternal": true, | |||
"composite": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents a caching issue and we don't need the composite anymore.
@@ -9,7 +9,6 @@ import { | |||
ProcessStreamResponse, | |||
subsystem, | |||
} from '@launchdarkly/js-sdk-common'; | |||
import { LDStreamProcessor } from '@launchdarkly/js-sdk-common/dist/api/subsystem'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import should not have been allowed.
When using typescript with moduleResolution set to "node16" types were not loading which are part of the common package.
This relates to changes to the default was in which file resolution occurs.
This PR will address this, but we will want a better long-term fix. In this PR we convince node that the
.d.ts
files are the correct extension by making a smallpackage.json
that sets the module type.In the future we would want the
.d.ts
files to instead be.d.cts
.Potentially we can move to tsup: https://tsup.egoist.dev/
But the changes were too extensive for this fix.
Testing:
tsconfig.json
package.json
Code:
This uses a few types, such as the context, logger, and options to ensure they are resolving correctly.